import { FETCH_SLIDER, FETCH_HOT, FETCH_NEWS, FETCH_GOUP, FETCH_GOUPITEM } from '../../constants/actionTypes'
import createLogger from 'vuex/dist/logger'
export default {
    state: {
        sliderload: [],
        hotload: [],
        newsload: [],
        goupload: [],
        goupitemload: [],
        totals: 0
    },
    getters: {
        sliderLoad(state) {
            return state.sliderload
        },
        hotLoad(state) {
            return state.hotload
        },
        newsLoad(state) {

            return state.newsload
        },
        newsTotals(state) {
            return state.totals
        },
        groupLoad(state) {
            return state.goupload
        },
        groupItemLoad(state) {
            return state.goupitemload
        }
    },
    mutations: {
        [FETCH_SLIDER](state, sliderload) {
            state.sliderload = sliderload;
            Object.assign({}, state, sliderload)
        },
        [FETCH_HOT](state, hotload) {
            state.hotload = hotload;
            Object.assign({}, state, hotload)
        },
        [FETCH_GOUP](state, goupload) {
            state.goupload = goupload;
            Object.assign({}, state, goupload)
        },
        [FETCH_GOUPITEM](state, goupitemload) {
            state.goupitemload = goupitemload;
            Object.assign({}, state, goupitemload)
        },
        [FETCH_NEWS](state, list) {
            state.newsload = list.list;
            state.totals = list.totals
            state.limit = list.limit
            return Object.assign({}, state)
        }
    },
    actions: {
        /** 获取轮播*/
        [FETCH_SLIDER]({commit}, sliderload) {
            commit(FETCH_SLIDER, sliderload)
        },
        /** 获取热门公众号*/
        [FETCH_HOT]({commit}, hotload) {
            commit(FETCH_HOT, hotload)
        },
        /** 获取分类项*/
        [FETCH_GOUP]({commit}, goupload) {
            commit(FETCH_GOUP, goupload)
        },
        /** 获取分类内容*/
        [FETCH_GOUPITEM]({commit}, goupitemload) {
            commit(FETCH_GOUPITEM, goupitemload)
        },
        /** 获取头条*/
        [FETCH_NEWS]({commit}, list) {
            commit(FETCH_NEWS, list)
        }
    }
}